<template>
  <div>
    <p>
      <input type="text" v-model="info.name" />
    </p>
    <p>
      <input type="text" v-model="info.text" />
    </p>
    <p>
      <button @click="pub">发布</button>
    </p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      info: {
        name: "",
        text: "",
      },
    };
  },
  methods: {
    pub() {
      // this.info.date = Date.now(); 
      let date = new Date()
      date = date.getTime()
      //  this.$set 数据改为响应式
    this.$set(this.info,"date",date)
      //发送
      this.$bus.$emit("sendInfo", JSON.parse(JSON.stringify(this.info)))

         
      console.log(this.$bus);
      // console.log(this.info);

      // this.info.name = "";
      // this.info.text = "";
    },
  },
};
</script>

<style>
p{
  margin-bottom: 20px;
}
</style>
